package com.xinchuang.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xinchuang.entity.DfQuotationPrice;
import com.xinchuang.mapper.DfQuotationPriceMapper;
import com.xinchuang.service.IDfQuotationPriceService;
import org.apache.commons.compress.utils.Lists;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class IDfQuotationPriceServiceImpl extends ServiceImpl<DfQuotationPriceMapper, DfQuotationPrice> implements IDfQuotationPriceService {
    public void init(String moldSelectionId, String detailId) {
        List<DfQuotationPrice> list = Lists.newArrayList();
        for(DfQuotationPriceEnum d : DfQuotationPriceEnum.values()) {
            DfQuotationPrice dfQuotationPrice = new DfQuotationPrice();
            dfQuotationPrice.setMoldSelectionId(moldSelectionId);
            dfQuotationPrice.setDetailId(detailId);
            dfQuotationPrice.setType(d.type);
            dfQuotationPrice.setName(d.name);
            list.add(dfQuotationPrice);
        }
        saveBatch(list);
    }

    public enum DfQuotationPriceEnum {
        TEMPERED("热处理/Heat Treatment", "调质/Tempered");
        private String type;
        private String name;

        DfQuotationPriceEnum(String type, String name) {
            this.type = type;
            this.name = name;
        }
    }
}

